home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000387_fdc@columbia.edu_Sun Sep 5 16:18:49 2004.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Path: newsmaster.cc.columbia.edu!not-for-mail
  2. From: Frank da Cruz <fdc@columbia.edu>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: GPS NMEA time reader
  5. Date: 5 Sep 2004 20:17:58 GMT
  6. Organization: Columbia University
  7. Lines: 100
  8. Message-ID: <slrncjmt3m.4t1.fdc@sesame.cc.columbia.edu>
  9. References: <ch4m71$koi$2@blue.rahul.net> <slrncjbtvl.iqr.fdc@sesame.cc.columbia.edu> <78889$413b33a0$44a75e7a$24367@msgid.meganewsservers.com>
  10. Reply-To: fdc@columbia.edu
  11. NNTP-Posting-Host: sesame.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1094415478 1830 128.59.59.56 (5 Sep 2004 20:17:58 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 5 Sep 2004 20:17:58 GMT
  15. User-Agent: slrn/0.9.8.0 (SunOS)
  16. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15158
  17.  
  18. On 2004-09-05, Robert Bonomi <bonomi@host122.r-bonomi.com> wrote:
  19. : In article <slrncjbtvl.iqr.fdc@sesame.cc.columbia.edu>,
  20. : Frank da Cruz  <fdc@columbia.edu> wrote:
  21. :>...
  22. :>: This is from 010904 September 1, 2004, at 13:40:58 GMT
  23. :>: Once satellite lock is found, the position appears
  24. :>: $GPRMC,134058,A,3850.1234,N,12230.5678,W,0.0,71.4,010904,15.0,E,A*0D
  25. :>:        ------                                     ------
  26. :>: Before satellite lock is found, there is no position, and no time.
  27. :>: The ",V," indicates that the fix is no good.
  28. :>: $GPRMC,,V,,,,,,,010904,15.0,E,N*00
  29. :>:
  30. :>You didn't say how to decode these, but if a time is in there, Kermit
  31. :>string and date/time functions can deal with it.  As to actually setting
  32. :>the system time, you'll need to invoke an external program (RUN or RUN START)
  33. :>with appropriate command line options and privileges.
  34. :
  35. :
  36. : The 'decoding' is obvious.  <grin>
  37. : The 2nd field is HHMMSS, the 11th field is DDMMYY
  38. : (note: decoding derived from his supplied data, with the plain-text 
  39. :        explanation line that precedes it, and his underlining of 
  40. :        fields 2 and 11.)
  41. :
  42. Hey, no making fun of me!  OK, fine, here is a more helpful response.
  43. The record is a comma-seperated list.  How to extract the date and time?
  44.  
  45.   .\%a = $GPRMC,134058,A,3850.1234,N,12230.5678,W,0.0,71.4,010904,15.0,E,A*0D
  46.   echo \fsplit(\%a,&a,{,},$.*)
  47.  
  48. This splits the string items into the array \&a[], using comma as the item
  49. separator, and treating dollar sign, period, and asterisk as data characters.
  50. Here's the result:
  51.  
  52.   show array a
  53.   \&a[]: Dimension = 13
  54.     0. 13
  55.     1. $GPRMC
  56.     2. 134058
  57.     3. A
  58.     4. 3850.1234
  59.     5. N
  60.     6. 12230.5678
  61.     7. W
  62.     8. 0.0
  63.     9. 71.4
  64.    10. 010904
  65.    11. 15.0
  66.    12. E
  67.    13. A*0D
  68.  
  69. Now \&a[10] is the date and \&a[2] is the time.  The date format used in
  70. the message is totally ambiguous (yes, *we* know it's ddmmyy but...) so we
  71. have to convert it to something parsable:
  72.  
  73.   .d := \&a[10]  ; Date (notational convenience)
  74.   .time := 20\s(d[5:2])\s(d[3:2])\s(d[1:2])_\&a[2]
  75.   date \m(time)
  76.   20040901 13:40:58
  77.  
  78. But it's GMT not local time so we must convert; easy:
  79.  
  80.   date \m(time)GMT
  81.   20040901 09:40:58
  82.  
  83. Programmatically:
  84.  
  85.   .time := \fcvtdate(\m(time)GMT)
  86.   echo \m(date)
  87.   20040901 09:40:58
  88.  
  89. Now to program this we have to allow for the degenerate form and we might
  90. also have to convert the result into some other format.  Assuming we have
  91. read a satellite record into the variable \%a:
  92.  
  93.   void \fsplit(\%a,&a,{,},$.*)
  94.   if ( def \&a[2] && def \&a[10] ) {
  95.      .t := \&a[2]
  96.      .time := \fcvtdate(20\s(d[5:2])\s(d[3:2])\s(d[1:2])_\&a[2]GMT)
  97.      echo "Setting time to \m(time)..."
  98.      run xxx \m(time) ; external command to set system time
  99.   } else {
  100.      end 1 "Date-time not not set"
  101.   }
  102.  
  103. The external time-setting command might require a different operand format.
  104. \vcvtdate() accepts an optional second argument to specify the format of
  105. the result:
  106.  
  107.   n1 = 1: yyyy-mmm-dd hh:mm:ss (mmm = English 3-letter month abbreviation)
  108.   n1 = 2: dd-mmm-yyyy hh:mm:ss (ditto)
  109.   n1 = 3: yyyymmddhhmmss (all numeric)
  110.  
  111. Others can be done with string processing as illustrated above with the
  112. date.  You might also need to discard the date portion of the date-time
  113. string and keep just the time:
  114.  
  115.   .time := \fword(\m(time),2,\32,:)
  116.  
  117. - Frank